package com.example.afinal;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class JiFenQiActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ji_fen_qi);
    }

    int Score1,Score2;

    public void click(View bt)
    {
        if(bt.getId()==R.id.bt1)
        {
            updateScore(3);
        } else if (bt.getId()==R.id.bt2) {
            updateScore(2);
        } else if (bt.getId()==R.id.bt3) {
            updateScore(1);
        }
    }

    public void click1(View bt)
    {
        if(bt.getId()==R.id.bt5)
        {
            updateScore1(3);
        } else if (bt.getId()==R.id.bt6) {
            updateScore1(2);
        } else if (bt.getId()==R.id.bt7) {
            updateScore1(1);
        }
    }


    private void updateScore(int i)
    {
        TextView scoreText = findViewById(R.id.Score1);
        Score1 += i;
        scoreText.setText(String.valueOf(Score1));
    }

    private void updateScore1(int i)
    {
        TextView scoreText1 = findViewById(R.id.Score2);
        Score2 += i;
        scoreText1.setText(String.valueOf(Score2));
    }

    public void resetCllick(View bt)
    {
        TextView scoreText = findViewById(R.id.Score1);
        TextView scoreText1 = findViewById(R.id.Score2);
        scoreText.setText(String.valueOf(0));
        scoreText1.setText(String.valueOf(0));
    }

}